package com.indexingsystem.system.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.indexingsystem.boss.Vo.ResourceTypeSelectVo;
import com.indexingsystem.boss.admin.mapper.ResourceTypeMapper;
import com.indexingsystem.boss.common.PagedResult;
import com.indexingsystem.boss.entity.ResourceType;
import com.indexingsystem.boss.utils.BeanUtils;
import com.indexingsystem.system.service.IResourceTypeService;

@Service
public class ResourceTypeServiceImpl implements IResourceTypeService {

	@Resource
	private ResourceTypeMapper resourceTypeMapper;

	/**
	 * 根据资源类型id删除资源类型.
	 * 
	 * @param resTypeId
	 * @return
	 */
	@Override
	public int deleteByPrimaryKey(String resTypeId) {
		return resourceTypeMapper.deleteByPrimaryKey(resTypeId);
	}

	/**
	 * 新增资源类型.
	 * 
	 * @param record
	 * @return
	 */
	@Override
	public int insertSelective(ResourceType record) {
		return resourceTypeMapper.insertSelective(record);
	}

	/**
	 * 通过资源类型id查询资源类型信息.
	 * 
	 * @param resTypeId
	 * @return
	 */
	@Override
	public ResourceType selectByPrimaryKey(String resTypeId) {
		return resourceTypeMapper.selectByPrimaryKey(resTypeId);
	}

	/**
	 * 修改资源类型.
	 * 
	 * @param record
	 * @return
	 */
	@Override
	public int updateByPrimaryKeySelective(ResourceType record) {
		return resourceTypeMapper.updateByPrimaryKeySelective(record);
	}

	/**
	 * 分页查询资源类型列表.
	 * 
	 * @param pageNo
	 * @param pageSize
	 * @return
	 */
	@Override
	public PagedResult<ResourceType> selectResourceTypeList(String queryCriteria,Integer pageNo, Integer pageSize) {
		pageNo = pageNo == null ? 1 : pageNo;
		pageSize = pageSize == null ? 10 : pageSize;
		// startPage是告诉拦截器说我要开始分页了。分页参数是这两个。
		PageHelper.startPage(pageNo, pageSize);
		return BeanUtils.toPagedResult(resourceTypeMapper.selectResourceTypeList(queryCriteria));
	}
	
	/**
	 * 弹窗资源类型获取列表.
	 * @return
	 */
	@Override
	public List<ResourceTypeSelectVo> getResourceTypeList(){
		return resourceTypeMapper.getResourceTypeList();
	}
	
	   /**
     * 获取资源类型总列表.
     * @return
     */
	@Override
    public List<ResourceType> getResourceTypeAllList(){
        return resourceTypeMapper.getResourceTypeAllList();
    }
	
	

	/**
	 * 获取资源类型总数量.
	 * 
	 * @return
	 */
	@Override
	public Integer getResourceTypeListCount(String queryCriteria) {
		return resourceTypeMapper.getResourceTypeListCount(queryCriteria);
	}

	/**
	 * 通过资源类型名称和英文名查询资源类型是否重复.
	 * @param resourceType
	 * @return
	 */
	@Override
	public ResourceType selectResourceTypeExits(ResourceType resourceType) {
		return resourceTypeMapper.selectResourceTypeExits(resourceType);
	}
	
	/**
	 * 通过资源类型名称查询资源类型是否重复.
	 * @param name
	 * @return
	 */
	@Override
	public ResourceType selectResourceTypeNameExits(String name){
		return resourceTypeMapper.selectResourceTypeNameExits(name);
	}
	
	/**
	 * 通过资源类型英文名查询资源类型是否重复.
	 * @param enName
	 * @return
	 */
	@Override
	public ResourceType selectResourceTypeEnNameExits(String enName){
		return resourceTypeMapper.selectResourceTypeEnNameExits(enName);
	}
	
	/**
	 * 通过资源类型资源明细表查询资源类型是否重复.
	 * @param resTable
	 * @return
	 */
	@Override
	public ResourceType selectResourceTypeResTableExits(String resTable){
		return resourceTypeMapper.selectResourceTypeResTableExits(resTable);
	}
	
	/**
	 * 批量删除资源类型.
	 * @param resourceTypeIdList
	 * @return
	 */
    public int deleteResourceTypeByIdBatch(List<String> resourceTypeIdList){
    	return resourceTypeMapper.deleteResourceTypeByIdBatch(resourceTypeIdList);
    }

    
    /*
     * 查询寻资源分类
     * */
	@Override
	public List<ResourceType> selectByAll() {
		return resourceTypeMapper.selectByAll();
	}
}